This library
will allow you to have a timer in your program without the need
of having a form in which place a control. This is more
convenient, for example, for classes and Windows NT services.
By the way, you
should also check the Common Controls
Replacement Project web site. These guys are doing a great job, and
they have a library which does the same as this one, but with a
few more features. The author of that library is Karl E. Peterson, who also has his own web site.
Objects:
In the library
there are two objects, ARTimer and ARCountdown. Use ARTimer to
receive an event every certain amount of time. Use ARCountdown if
you just want to receive an event after a certain amount of time,
and you don't want the timer to keep going.
AR TIMER: |
AR COUNTDOWN: |
Properties:
- Interval.
Set this in milliseconds.
- Running.
Read-only; true of the timer is running and false
if it is not.
Methods:
- StartTimer.
This starts the timer.
- StopTimer.
This stops the timer.
Events:
- Timer
(TT_H As Long, TT_M As Long, TT_S As Long, TT_MS
As Long). This event will be fired every time
that the amount of time set in Interval is
elapsed. TT_H, TT_M, TT_S and TT_MS will contain
the total amount of time elapsed since the timer
was started. For convenience, hours, minutes,
seconds and milliseconds are given in different
variables.
|
Properties:
- Interval.
Set this in milliseconds.
- Running.
Read-only; true of the counter is running and
false if it is not.
Methods:
- StartCountdown.
Starts the countdown.
- StopCountdown.
Stops the countdown.
Events:
- Done.
This event is fired once the time has elapsed. If
you want to run the countdown again, use the
StartCountdown method.
|
History:
- 05.04.98,
Version 1.0 released.
- Version 2.0
01.05.98: the timer objects have been replaced by the
multimedia ones, getting much higher precission. Now the
library is also smaller.
Considerations:
- You will
have to dimension the variable using an instruction like
this in the Declarations section of wherever you want to
use the object:
Private
Withevents Timer as ARTimer
Then, in the
Load event of the form or the Initialize of the class, put
this instruction:
Set
Timer = New ARTimer
- The
'Withevents' modifier will give you access to the event
provided by the object. Just select it as you would
select an event of any other object.
- You will
not be able to use the 'Withevents' modifier in a code
module, just in classes, forms and controls.
- I have
experienced problems when setting the timer to a very
small value, like less than 10 milliseconds (in
programming environment). This seems to happen when
Visual Basic is not able to process so many instructions
per second.
© Alvaro Redondo, 1998. All Rights Reserved.
http://www.sevillaonline.com/ActiveX